<%@ include file="/common/taglibs.jsp"%>
<%@ page language="java" pageEncoding="UTF-8"%>	
<%@ taglib prefix="sales" tagdir="/WEB-INF/tags/sales"%>
<%@ taglib prefix="catalog" tagdir="/WEB-INF/tags/catalog"%>
<title><fmt:message key="giftCouponQuery.title" /></title>
<content tag="position">
	<fmt:message key="accountMenu.coupon" />&gt; <b><fmt:message key="giftCouponQuery.title" /></b>
</content>

<%
	String url = request.getAttribute("preUrl").toString();
	request.setAttribute("noCustomer", url.indexOf("customer")==-1);
 %>
<div <c:if test="${noCustomer}">class="wrap_11"</c:if> >
	<div <c:if test="${noCustomer}">class="wrap_05"</c:if> >
		<div class="coupon_search">
			<form action="giftCouponQuery.html" method="post" name="giftCouponQueryForm" id="giftCouponQueryForm" onsubmit="return queryGiftCouponNo();">
				<p>
					<fmt:message key="giftCouponQuery.desc" /><br/><br/>
					<fmt:message key="giftCouponQuery.field" />：
					<input name="giftCouponNo" id="giftCouponNo" type="text" style="width:180px" class="inputtxt2" autocomplete="off"/> 
					<input type="hidden" name="doAction" value="queryGiftCouponAction"/>	
					<input type="submit" value="" class="btn_search" />
				</p>
			</form>	
			<ins></ins>
		</div>
		<c:choose>
			<c:when test="${not empty coupon or not empty giftCertificate}">
				<c:choose>
					<%---------------------------------start:有效优惠券 -------------------------%>
					<c:when test="${coupon.state == 1}">
						<div class="coupon_img">
							<h4><fmt:message key="giftCouponQuery.couponInformation" /></h4>
							
							<div class="block2">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<th><fmt:message key="giftCouponQuery.couponNo" /> </th>
										<td class="s1">${coupon.couponNo}</td>
									</tr>
									<tr>
										<th><fmt:message key="giftCouponQuery.remainTimes" /> </th>
										<td class="s2">${coupon.remainedTimes}</td>
									</tr>
									<tr>
										<th><fmt:message key="giftCouponQuery.expiredTime" /></th>
										<td>
											<c:choose>
												<c:when test="${not empty coupon.promoRule.endTime}">
													<fmt:formatDate value="${coupon.promoRule.endTime}"
														pattern="yyyy-MM-dd" />
												</c:when>
												<c:otherwise>
													<fmt:message key="giftCouponQuery.noEndTime"></fmt:message>
												</c:otherwise>
											</c:choose>
										</td>
									</tr>
									<tr>
										<th><fmt:message key="giftCouponQuery.promoRule" /></th>
										<td>
											<a target="_blank"	href="<sales:promoRuleUrl promoRuleId="${coupon.promoRule.promoRuleId}"/>">
											${coupon.promoRule.name}&nbsp;</a>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</c:when>
					<%---------------------------------end:  有效优惠券 -------------------------%>
					<%---------------------------------start:有效礼券   -------------------------%>
					<c:when test="${giftCertificate.frontState == 1}">
						<div class="coupon_img">
							<h4><fmt:message key="giftCouponQuery.giftInfo" /></h4>
							
							<div class="block1">
								<table width="100%" border="0" cellspacing="0" cellpadding="0">
									<tr>
										<th><fmt:message key="giftCouponQuery.giftNo" /></th>
										<td class="s1">${giftCertificate.giftCertificateNo}</td>
									</tr>
									<tr>
										<th><fmt:message key="giftCouponQuery.originalAmount" /> </th>
										<td class="s3"><common:currencyFormat value="${giftCertificate.giftCertAmt}" /></td>
									</tr>
									<tr>
										<th><fmt:message key="giftCouponQuery.remainedAmount" /></th>
										<td class="s2">
											<common:currencyFormat value="${giftCertificate.remainedAmt}" />
										</td>
									</tr>
									<tr>
										<th><fmt:message key="giftCouponQuery.expiredTime" /></th>
										<td>
											<c:choose>
												<c:when test="${not empty giftCertificate.expireTime}">
													<fmt:formatDate value="${giftCertificate.expireTime}"
														pattern="yyyy-MM-dd" />
												</c:when>
												<c:otherwise>
													<fmt:message key="giftCouponQuery.noEndTime"></fmt:message>
												</c:otherwise>
											</c:choose>
										</td>
									</tr>
								</table>
							</div>
						</div>
					</c:when>
					<%---------------------------------end: 有效礼券   -------------------------%>
					<%---------------------------------start:无效提示   -------------------------%>
					<c:otherwise>
					
						<div class="msg">
							<h3><fmt:message key="giftCouponQuery.tip" />：</h3>
							<div class="error_info">
								<c:choose>
									<c:when test="${not empty coupon and coupon.state != 0}">
										<fmt:message key="giftCouponQuery.coupon.state${coupon.state}">
											<fmt:param>${giftCouponNo}</fmt:param>
										</fmt:message>
									</c:when>
									<c:when	test="${not empty giftCertificate and giftCertificate.frontState != 0}">
										<fmt:message
											key="giftCouponQuery.giftCertificate.frontState.${giftCertificate.frontState}">
											<fmt:param>${giftCouponNo}</fmt:param>
										</fmt:message>
									</c:when>
									<c:when
										test="${coupon.state == 0 and giftCertificate.frontState == 0}">
										<fmt:message key="giftCouponQuery.notExist">
											<fmt:param>${giftCouponNo}</fmt:param>
										</fmt:message>
									</c:when>
									<c:otherwise>
									</c:otherwise>
								</c:choose> 
							</div>
						</div>
					</c:otherwise>
					<%---------------------------------end: 无效提示   -------------------------%>
					
				</c:choose>
			</c:when>	
			<c:otherwise>
				<div class="msg">
					<h3><fmt:message key="giftCouponQuery.tip" />：</h3>
					<div class="error_info">
						<fmt:message key="giftCouponQuery.notExist">
							<fmt:param>${giftCouponNo}</fmt:param>
						</fmt:message>
					</div>
				</div>	
			</c:otherwise>
		</c:choose>
		
		
		<div>
			<br/>
			<br/>
			<div>
				<catalog:getContentCategory categoryCode="couponUse" returnCategoryName="couponUse"></catalog:getContentCategory>
				${couponUse.categoryContext}
			</div>
			<div>
				<catalog:getContentCategory categoryCode="giftcertificateUse" returnCategoryName="giftcertificateUse"></catalog:getContentCategory>
				${giftcertificateUse.categoryContext}
			</div>
		</div>
	</div>
</div>







<script type="text/javascript">
function queryGiftCouponNo(){
	if(trim($("giftCouponNo").value)==""){
		alert("<fmt:message key="giftCouponQuery.submitConfirm"/>");
		return false;
	}
	return true;
}
</script>